package com.sunwayworld.basemodule.business.pjreport.dao.impl;

import com.sunwayworld.framework.mybatis.mapper.MapperParameter;
import com.sunwayworld.framework.support.PersistableHelper;
import com.sunwayworld.module.item.file.bean.CoreFileBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.sunwayworld.basemodule.business.pjreport.bean.LimsPjReportBean;
import com.sunwayworld.basemodule.business.pjreport.dao.LimsPjReportDao;
import com.sunwayworld.basemodule.business.pjreport.mapper.LimsPjReportMapper;
import com.sunwayworld.framework.mybatis.dao.MybatisDaoSupport;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Repository
@GikamBean
public class LimsPjReportDaoImpl extends MybatisDaoSupport<LimsPjReportBean, Long> implements LimsPjReportDao {

    @Autowired
    private LimsPjReportMapper limsPjReportMapper;

    @Override
    public LimsPjReportMapper getMapper() {
        return limsPjReportMapper;
    }
    @Override
    public List<CoreFileBean> selectFileByCondition(MapperParameter temp) {
        List<Map<String,Object>> mapList = getMapper().selectFileByCondition(temp);
        if (mapList.isEmpty()){
            return Collections.emptyList();
        }
        return  mapList.stream().map(m-> PersistableHelper.mapToPersistable(m,CoreFileBean.class)).collect(Collectors.toList());
    }
}
